<?php

/**
 * parser
 *
 * @author Admin
 */
class Parser_Comment extends Model_Abstract
{
    protected $_table_name = 'parsed_comment';

    public function check( $comment )
    {
		$fields = array(
			'comment' => $comment
		);

		$fields = $this->_paramsToString($fields);

		$sql = "SELECT * FROM " . $this->_table_name . " WHERE " . $fields;
		$rows = $this->_db->get_results($sql);
		
		return $rows;
    }

    public function insert( $parser_id, $news_id, $item_id, $comment )
    {
		$fields = array(
			'parser_id' => $parser_id,
			'news_id' => $news_id,
			'item_id' => $item_id,
			'comment' => $comment
		);

		$fields = $this->_paramsToString($fields);

		$sql = "INSERT INTO " . $this->_table_name . " SET " . $fields;
		$this->_db->get_results($sql);

		return $this->_getLastInsertId();
    }
    
    public function update( $id, $parser_id = false, $news_id = false, $item_id = false, $comment = false )
    {
		$fields = array(
			'parser_id' => $parser_id,
			'news_id' => $news_id,
			'item_id' => $item_id,
			'comment' => $comment
		);

		$fields = $this->_paramsToString($fields);

		$sql = "UPDATE " . $this->_table_name . " SET " . $fields . " WHERE id = $id";
		return $this->_db->get_results($sql);
    }
    
    
}